package org.bultreebank.testing;

import java.util.Date;

import org.bultreebank.extractor.Extractor;
import org.bultreebank.index.utils.Utils;
import org.bultreebank.search_engine.SearchEngine;
import org.bultreebank.search_engine.SearchEngineImpl;
import org.w3c.dom.Document;

public class ConceptAnnotationSearchTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try
		{
			String queryStringPath = "Test/Query_text.xml";
			SearchEngine engine = SearchEngineImpl.getInstance("Test/IndexRepository");
			String queryContent = Utils.getStringRepresentationOfFileContent(queryStringPath);
			Date start =  new Date();
			StringBuffer buf = new StringBuffer();
			buf.append("**** SEARCHING IN INDEX 'ConceptAnnotationIndex' ****\n");
			String[] result = engine.search(queryContent, "TextIndex");
			StringBuffer buff = new StringBuffer();
			for (String res:result)
				buff.append(res + "\n");
			Date end = new Date();
			buf.append("Period: " + (double) ((end.getTime() - start.getTime())/1000) + "\n");
			Utils.saveFile("Test/SearchStatus_3", buf.toString());
			
			Utils.saveFile("Test/SearchResult_3.xml", buff.toString());
			Extractor extractor = ((SearchEngineImpl) engine).getExtractor();
			Document formattedRes = extractor.getFormatedDocument(result);
			Utils.saveDocument("Test//FormatedResult_3.xml", null, formattedRes);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	

}



